//
//  WPMinePrescriptionRecordsVC.m
//  wobingwoyi
//
//  Created by WGP on 16/8/30.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPMinePrescriptionRecordsVC.h"
#import "WPMinePlaceholderTextView.h"
#import "WPPickerView.h"
#import "WPCommentBtn.h"
#import "HMDatePicker.h"
#import "WPMRModel.h"
#import "WPMedicalRecordsVC.h"
#import "WPMineLoginVC.h"

@interface WPMinePrescriptionRecordsVC ()<HMDatePickerDelegate>

@property(nonatomic,strong)UIView *statusView;
@property(nonatomic,strong)UIView *navView;
@property(nonatomic,strong)UIScrollView *bgScrollView;
@property(nonatomic,strong)UIView *firstView;
@property(nonatomic,strong)UIView *secondView;
@property(nonatomic,strong)UIView *thirdView;
@property(nonatomic,strong)UILabel *sexLabel;
@property(nonatomic,strong)UILabel *ageLabel;
@property(nonatomic,strong)UILabel *timeLable;
@property(nonatomic,strong)UIButton *sexBtn;
@property(nonatomic,strong)UIButton *ageBtn;
@property(nonatomic,strong)WPCommentBtn *timeBtn;
@property(nonatomic,strong)UITextField *nameField;
@property(nonatomic,strong)UITextField *diseaseField;
@property(nonatomic,strong)WPMinePlaceholderTextView *textView;
@property(nonatomic,strong)UITextField *doctorField;
@property(nonatomic,strong)UITextField *hosField;

@property(nonatomic,strong)NSArray *sexArr;
@property(nonatomic,strong)NSMutableArray *ageArr;

@end

@implementation WPMinePrescriptionRecordsVC

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = GlobalBgColor;
    [self setupUI];
}

-(void)setupUI
{
    [self statusView];
    [self navView];
    [self bgScrollView];
    [self firstView];
    //        方法过长,在别的方法里添加其他子控件
    [self setupOtherSubViews];
    [self secondView];
    [self thirdView];
}

-(UIView *)statusView
{
    if (_statusView == nil)
    {
        _statusView = [UIView new];
        _statusView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_statusView];
        
        [_statusView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.equalTo(self.view);
            make.height.mas_equalTo(20);
        }];
    }
    return _statusView;
}

-(UIView *)navView
{
    if (_navView == nil)
    {
        _navView = [UIView new];
        _navView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_navView];
        
        [_navView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.statusView.mas_bottom);
            make.left.right.equalTo(self.view);
            make.height.mas_equalTo(44);
        }];
        
        UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
        [cancelBtn addTarget:self action:@selector(cancelBtnDidClick:) forControlEvents:UIControlEventTouchUpInside];
        [cancelBtn setTitleColor:GLobalFontColor forState:UIControlStateNormal];
        cancelBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_navView addSubview:cancelBtn];
        
        UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [saveBtn setTitle:@"保存" forState:UIControlStateNormal];
        [saveBtn addTarget:self action:@selector(saveBtnDidClick:) forControlEvents:UIControlEventTouchDown];
        [saveBtn setTitleColor:GLobalFontColor forState:UIControlStateNormal];
        saveBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_navView addSubview:saveBtn];
        
        UILabel *titleLabel = [UILabel new];
        titleLabel.text = @"处方记录";
        titleLabel.textColor = GLobalFontColor;
        titleLabel.font = [UIFont systemFontOfSize:18];
        [_navView addSubview:titleLabel];
        
        UIImageView *lineImageView = [self lineImageView];
        [_navView addSubview:lineImageView];
        
        [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_navView);
            make.left.equalTo(_navView).offset(15);
        }];
        
        [saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_navView);
            make.right.equalTo(_navView).offset(-15);
        }];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(_navView);
        }];
        
        [lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0.5);
            make.left.right.bottom.equalTo(_navView);
        }];
    }
    return _navView;
}

-(UIScrollView *)bgScrollView
{
    if(_bgScrollView == nil)
    {
        _bgScrollView = [[UIScrollView alloc] init];
        _bgScrollView.backgroundColor = GlobalBgColor;
        [self.view addSubview:_bgScrollView];
        
        [_bgScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self.view);
            make.top.equalTo(self.navView.mas_bottom);
        }];
    }
    return _bgScrollView;
}

//给UISCrollView添加子控件不能以scroillView为参照
-(UIView *)firstView
{
    if (_firstView == nil)
    {
        _firstView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 132-44)];
        _firstView.backgroundColor = [UIColor whiteColor];
        [self.bgScrollView addSubview:_firstView];
        
        UIImageView *topLine = [self lineImageView];
        UIImageView *bottomLine = [self lineImageView];
        UIImageView *secondLine = [self lineImageView];
        
        UILabel *sexLabel = [self labelWith:@"性别"];
        self.sexLabel = sexLabel;
        UILabel *ageLabel = [self labelWith:@"年龄"];
        self.ageLabel = ageLabel;
        UILabel *timeLabel = [self labelWith:@"就诊日期"];
        self.timeLable = timeLabel;
        UILabel *diseaseLabel = [self labelWith:@"临床诊断"];
        
        [_firstView addSubview:topLine];
        [_firstView addSubview:bottomLine];
        [_firstView addSubview:secondLine];
        [_firstView addSubview:sexLabel];
        [_firstView addSubview:ageLabel];
//        [_firstView addSubview:nameLabel];
        [_firstView addSubview:timeLabel];
        [_firstView addSubview:diseaseLabel];
        
        [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.equalTo(_firstView);
            make.height.mas_equalTo(0.5);
        }];
        
        [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(_firstView);
            make.height.mas_equalTo(0.5);
        }];
        
        [secondLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_firstView).offset(15);
            make.top.equalTo(_firstView).offset(44);
            make.right.equalTo(_firstView);
            make.height.mas_equalTo(0.5);
        }];
        
        CGSize size = [sexLabel.text sizeWithMaxSize:CGSizeMake(MAXFLOAT, MAXFLOAT) font:14];
        [sexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_firstView).offset(-100);
            make.top.equalTo(topLine.mas_bottom);
            make.bottom.equalTo(secondLine.mas_top);
            make.width.mas_equalTo(size.width+1);
        }];
        
        [ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.height.equalTo(sexLabel);
            make.top.equalTo(secondLine.mas_bottom);
        }];
        
//        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.equalTo(sexLabel);
//            make.left.equalTo(_firstView).offset(15);
//        }];
        
        [diseaseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_firstView).offset(15);
            make.centerY.equalTo(sexLabel);
        }];
        
        CGSize timeSize = [timeLabel.text sizeWithMaxSize:CGSizeMake(MAXFLOAT, MAXFLOAT) font:14];
        [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(ageLabel);
            make.left.equalTo(diseaseLabel);
            make.width.mas_equalTo(timeSize.width+1);
        }];
    }
    return _firstView;
}

-(void)setupOtherSubViews
{
    UIButton *sexBtn = [self buttonWith:@"请选择性别"];
    [sexBtn addTarget:self action:@selector(sexBtnDidClick:) forControlEvents:UIControlEventTouchDown];
    [sexBtn setTitleColor:RGB_COLOR(208, 208, 213) forState:UIControlStateNormal];
    self.sexBtn = sexBtn;
    
    UIButton *ageBtn = [self buttonWith:@"请选择年龄"];
    [ageBtn setTitleColor:RGB_COLOR(208, 208, 213) forState:UIControlStateNormal];
    [ageBtn addTarget:self action:@selector(ageBtnDidClick:) forControlEvents:UIControlEventTouchDown];
    self.ageBtn = ageBtn;
//    UITextField *nameField = [self textFieldWith:@"请输入姓名"];
    
    WPCommentBtn *timeBtn = [self leftLabelButtonWith:@"请选择日期"];
    [timeBtn setTitleColor:RGB_COLOR(208, 208, 213) forState:UIControlStateNormal];
    [timeBtn addTarget:self action:@selector(timeBtnDidClick:) forControlEvents:UIControlEventTouchDown];
    self.timeBtn = timeBtn;
    
    UITextField *diseaseField = [self textFieldWith:@"请输入疾病名称"];
    self.diseaseField = diseaseField;
    
    [self.firstView addSubview:ageBtn];
    [self.firstView addSubview:sexBtn];
//    [self.firstView addSubview:nameField];
    [self.firstView addSubview:timeBtn];
    [self.firstView addSubview:diseaseField];
    
    [sexBtn mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self.sexLabel);
        make.left.equalTo(self.sexLabel.mas_right);
        make.right.equalTo(self.firstView);
    }];
    
    [ageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.ageLabel);
        make.left.equalTo(self.ageLabel.mas_right);
        make.right.equalTo(self.firstView);
    }];
    
//    [nameField mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.timeLable.mas_right).offset(10);
//        make.right.equalTo(self.sexLabel.mas_left);
//        make.centerY.equalTo(self.sexLabel);
//    }];
    
    [timeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLable);
        make.left.equalTo(self.timeLable.mas_right);
        make.right.equalTo(self.ageLabel.mas_left);
    }];
    
    [diseaseField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeLable.mas_right).offset(10);
        make.right.equalTo(self.sexLabel.mas_left);
        make.centerY.equalTo(self.sexLabel);
    }];
}

-(UIView *)secondView
{
    if (_secondView == nil)
    {
        _secondView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.firstView.frame)+10, SCREEN_WIDTH, 225+44)];
        _secondView.backgroundColor = [UIColor whiteColor];
        [self.bgScrollView addSubview:_secondView];
        
        UIImageView *topLine = [self lineImageView];
        UIImageView *bottomLine = [self lineImageView];
        UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"R"]];
        [iconView sizeToFit];
        UILabel *titleLabel = [self labelWith:@"处方单"];
        titleLabel.font = [UIFont systemFontOfSize:15];
        
        WPMinePlaceholderTextView *textView = [[WPMinePlaceholderTextView alloc] init];
        textView.placeholder = @"请编辑处方单...";
        textView.font = [UIFont systemFontOfSize:13];
        self.textView = textView;
        [_secondView addSubview:textView];
        
        [_secondView addSubview:topLine];
        [_secondView addSubview:bottomLine];
        [_secondView addSubview:iconView];
        [_secondView addSubview:titleLabel];
        
        [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(_secondView);
            make.height.mas_equalTo(0.5);
        }];
        
        [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(_secondView);
            make.height.mas_equalTo(0.5);
        }];
        
        [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(_secondView).offset(15);
        }];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(iconView);
            make.left.equalTo(iconView.mas_right).offset(10);
            
        }];
        
        [textView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_secondView).offset(15);
            make.right.equalTo(_secondView).offset(-15);
            make.bottom.equalTo(bottomLine.mas_top);
            make.top.equalTo(iconView.mas_bottom).offset(10);
        }];
    }
    return _secondView;
}

-(UIView *)thirdView
{
    if (_thirdView == nil)
    {
        _thirdView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.secondView.frame)+10, SCREEN_WIDTH, 88)];
        _thirdView.backgroundColor = [UIColor whiteColor];
        [self.bgScrollView addSubview:_thirdView];
        
        UIImageView *topLine = [self lineImageView];
        UIImageView *midLine = [self lineImageView];
        UIImageView *bottomLine = [self lineImageView];
        
        [_thirdView addSubview:topLine];
        [_thirdView addSubview:midLine];
        [_thirdView addSubview:bottomLine];
        
        UILabel *doctorLabel = [self labelWith:@"诊断医生"];
        UILabel *hosLabel = [self labelWith:@"诊断医院"];
        UITextField *doctorField = [self textFieldWith:@"请输入诊断医生"];
        self.doctorField = doctorField;
        UITextField *hosField = [self textFieldWith:@"请输入诊断医院"];
        self.hosField = hosField;
        
        [_thirdView addSubview:doctorLabel];
        [_thirdView addSubview:hosLabel];
        [_thirdView addSubview:doctorField];
        [_thirdView addSubview:hosField];
        
        
        [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(_thirdView);
            make.height.mas_equalTo(0.5);
        }];
        
        [midLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_thirdView).offset(15);
            make.right.equalTo(_thirdView);
            make.height.mas_equalTo(0.5);
            make.top.equalTo(_thirdView).offset(44);
        }];
        
        [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(_thirdView);
            make.height.mas_equalTo(0.5);
        }];
        
        [doctorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_thirdView).offset(15);
            make.top.equalTo(_thirdView).offset(1);
            make.bottom.equalTo(midLine.mas_top);
            make.width.mas_equalTo(60);
        }];
        
        [hosLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(doctorLabel);
            make.top.equalTo(midLine.mas_bottom);
            make.bottom.equalTo(bottomLine);
        }];
        
        [doctorField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(doctorLabel);
            make.left.equalTo(doctorLabel.mas_right).offset(10);
            make.right.equalTo(_thirdView);
        }];
        
        [hosField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(hosLabel);
            make.left.right.equalTo(doctorField);
            
        }];
    }
    return _thirdView;
}

#pragma mark - 按钮响应事件方法
-(void)cancelBtnDidClick:(UIButton *)btn
{
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)saveBtnDidClick:(UIButton *)btn
{
//    保存按钮点击
    
    if (self.diseaseField.text.length == 0 || self.sexBtn.titleLabel.text.length != 1 || [self.timeBtn.titleLabel.text isEqualToString:@"请选择日期"] || [self.ageBtn.titleLabel.text isEqualToString:@"请选择年龄"] || self.textView.text.length == 0 || self.doctorField.text.length == 0 || self.hosField.text.length == 0)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"友情提示" message:@"请把信息补充完整" delegate:nil cancelButtonTitle:@"知道了" otherButtonTitles:nil];
        [alert show];
        return ;
    }
    
//    屏幕截图
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(SCREEN_WIDTH, CGRectGetMaxY(self.thirdView.frame)), NO, 0.0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [self.bgScrollView.layer renderInContext:context];
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    NSString *totalPath = [documentPath stringByAppendingPathComponent:@"prescriptionRecords.jpg"];
    NSData *data = UIImageJPEGRepresentation(img, 1);
    [data writeToFile:totalPath atomically:NO];
    NSURL *imageURL = [NSURL fileURLWithPath:totalPath];
    
    WPMRModel *model = [WPMRModel new];
    model.name = self.diseaseField.text;
    model.age = [self.ageBtn.titleLabel.text intValue];
    model.sex = self.sexBtn.titleLabel.text;
//    model.descp = self.textView.text;
    model.treatmentTime = self.timeBtn.titleLabel.text;
    model.doctor = self.doctorField.text;
    model.hospital = self.hosField.text;
    
    NSString *url = @"record/addRecord.do";
    NSString *modelJSON = [model yy_modelToJSONString];
    NSDictionary *dict = @{@"json":modelJSON};
    
    [[WPNetWorkManager sharedNetWorkManager] POST:url parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
        [formData appendPartWithFileURL:imageURL name:@"file" error:nil];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *responseDict = (NSDictionary *)responseObject;
        
        if([responseDict[@"result"] isEqualToString:@"success"])
        {
            [self showSuccessInfoWithStatus:@"保存成功"];
            
            UIStoryboard *sb = [UIStoryboard storyboardWithName:@"WPMedicalRecordsVC" bundle:nil];
            WPMedicalRecordsVC *mrVC = [sb instantiateInitialViewController];
            mrVC.isHidden = YES;
            [self.navigationController pushViewController:mrVC animated:YES];
            
//            返回到我的中心
            mrVC.backBlock = ^
            {
                [self.navigationController popToRootViewControllerAnimated:YES];
            };
        }
        else
        {
            //            考虑到账号过期的情况
            if ([responseObject[@"detail"] isEqualToString:@"illegalLogin"])
            {
                //                账号过期
                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"账号过期,请重新登录" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
                [alertView show];
            }
            else
            {
                [self showErrorInfoWithStatus:@"保存失败"];
            }
        }

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self showErrorInfoWithStatus:@"网络错误"];
    }];
}

//重新登陆的代理方法
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
        if (buttonIndex == 0)
        {
            WPMineLoginVC *vc = [WPMineLoginVC new];
            [self presentViewController:[[UINavigationController alloc] initWithRootViewController:vc] animated:YES completion:nil];
        }
}

-(void)sexBtnDidClick:(UIButton *)btn
{
    [self.view endEditing:YES];
    
    WPPickerView *pickerView = [[WPPickerView alloc] initWithData:self.sexArr handleBlock:^(NSString *selectedData) {
        
        [self.sexBtn setTitleColor:GLobalFontColor forState:UIControlStateNormal];
        [self.sexBtn setTitle:selectedData forState:UIControlStateNormal];
    }];
    [pickerView show];
}


-(void)ageBtnDidClick:(UIButton *)btn
{
    [self.view endEditing:YES];
    
    WPPickerView *pickerView = [[WPPickerView alloc] initWithData:self.ageArr handleBlock:^(NSString *selectedData) {
        
        [self.ageBtn setTitleColor:GLobalFontColor forState:UIControlStateNormal];
        [self.ageBtn setTitle:selectedData forState:UIControlStateNormal];
    }];
    [pickerView show];
}

-(void)timeBtnDidClick:(UIButton *)btn
{
    [self.textView resignFirstResponder];
    
    // 创建日期选择器
    HMDatePicker *pickerView = [HMDatePicker datePicker];
    // 设置代理
    pickerView.delegate = self;
    // 设置datePicker当前显示的时间
    pickerView.currentDate = [NSDate date];
    // 显示
    [pickerView show];
}

- (void)datePickerDidValueChanged:(HMDatePicker *)datePicker
{
    [self.timeBtn setTitleColor:GLobalFontColor forState:UIControlStateNormal];
    
    [self.timeBtn setTitle:[[WPDateFormatterManager sharedManager] stringFromDateWithDate:datePicker.datePicker.date format:@"yyyy-MM-dd"] forState:UIControlStateNormal];
   
}


-(UIImageView *)lineImageView
{
    UIImageView *imageView = [UIImageView new];
    imageView.backgroundColor = GLobalLineColor;
    
    return imageView;
}

-(UILabel *)labelWith:(NSString *)text
{
    UILabel *label = [UILabel new];
    label.text = text;
    label.textColor = GLobalFontColor;
    label.font = [UIFont systemFontOfSize:14];
    [label sizeToFit];
    
    return label;
}

-(UITextField *)textFieldWith:(NSString *)placeholder
{
    UITextField *field = [UITextField new];
    field.placeholder = placeholder;
    field.font = [UIFont systemFontOfSize:14];
    field.textColor = GLobalFontColor;
    return field;
}

-(WPCommentBtn *)buttonWith:(NSString *)title
{
    WPCommentBtn *button = [WPCommentBtn buttonWithType:UIButtonTypeCustom];
    [button setTitleColor:GLobalFontColor forState:UIControlStateNormal];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:14];
    [button sizeToFit];
    
    return button;
}

-(WPCommentBtn *)leftLabelButtonWith:(NSString *)title
{
    WPCommentBtn *button = [WPCommentBtn buttonWithType:UIButtonTypeCustom];
    [button setTitleColor:GLobalFontColor forState:UIControlStateNormal];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:14];
    [button sizeToFit];
    
    return button;
}

-(NSMutableArray *)ageArr
{
    if (_ageArr == nil)
    {
        _ageArr = [NSMutableArray array];
        
        for (int i = 1; i <= 100; i++)
        {
            NSString *str = [NSString stringWithFormat:@"%zd",i];
            [_ageArr addObject:str];
        }
    }
    return _ageArr;
}

-(NSArray *)sexArr
{
    if (_sexArr == nil)
    {
        _sexArr = [NSArray arrayWithObjects:@"男",@"女", nil];
    }
    return _sexArr;
}

@end
